---
title: 图片
icon: ImagePlus
---

<MetaData
  lang="zh-CN"
  meta={{
    preset: [{
      client: '@univerjs/preset-docs-drawing',
      locale: '@univerjs/preset-docs-drawing/locales/zh-CN',
      style: '@univerjs/preset-docs-drawing/lib/index.css',
    }],
    plugins: [{
      client: '@univerjs/drawing',
    }, {
      client: '@univerjs/drawing-ui',
      locale: '@univerjs/drawing-ui/locale/zh-CN',
      style: '@univerjs/drawing-ui/lib/index.css',
    }, {
      client: '@univerjs/docs-drawing',
    }, {
      client: '@univerjs/docs-drawing-ui',
      locale: '@univerjs/docs-drawing-ui/locale/zh-CN',
      style: '@univerjs/docs-drawing-ui/lib/index.css',
    }],
    server: '否',
  }}
/>

图片可用于丰富文档内容、增强视觉表达和帮助说明或突出重点信息。

## 预设模式

### 安装

```package-install
npm install @univerjs/preset-docs-drawing
```

### 使用

```typescript
import { UniverDocsCorePreset } from '@univerjs/preset-docs-core'
import UniverPresetDocsCoreZhCN from '@univerjs/preset-docs-core/locales/zh-CN'
import { UniverDocsDrawingPreset } from '@univerjs/preset-docs-drawing' // [!code ++]
import UniverPresetDocsDrawingZhCN from '@univerjs/preset-docs-drawing/locales/zh-CN' // [!code ++]
import { createUniver, LocaleType, mergeLocales } from '@univerjs/presets'

import '@univerjs/preset-docs-core/lib/index.css'
import '@univerjs/preset-docs-drawing/lib/index.css' // [!code ++]

const { univerAPI } = createUniver({
  locale: LocaleType.ZH_CN,
  locales: {
    [LocaleType.ZH_CN]: mergeLocales(
      UniverPresetDocsCoreZhCN,
      UniverPresetDocsDrawingZhCN, // [!code ++]
    ),
  },
  presets: [
    UniverDocsCorePreset(),
    UniverDocsDrawingPreset(), // [!code ++]
  ],
})
```

如使用[协同编辑](/guides/docs/features/collaboration)功能，请确保在 `UniverDocsDrawingPreset` 中传入 `collaboration: true` 选项。

```typescript
UniverDocsDrawingPreset({
  collaboration: true, // [!code ++]
})
```

{/* ### 预设与配置 */}

## 插件模式

### 安装

```package-install
npm install @univerjs/drawing @univerjs/drawing-ui @univerjs/docs-drawing @univerjs/docs-drawing-ui
```

### 使用

```typescript
import { LocaleType, mergeLocales, Univer } from '@univerjs/core'
import { UniverDocsDrawingPlugin } from '@univerjs/docs-drawing' // [!code ++]
import { UniverDocsDrawingUIPlugin } from '@univerjs/docs-drawing-ui' // [!code ++]
import DocsDrawingUIZhCN from '@univerjs/docs-drawing-ui/locale/zh-CN' // [!code ++]
import { UniverDrawingPlugin } from '@univerjs/drawing' // [!code ++]
import { UniverDrawingUIPlugin } from '@univerjs/drawing-ui' // [!code ++]
import DrawingUIZhCN from '@univerjs/drawing-ui/locale/zh-CN' // [!code ++]

import '@univerjs/drawing-ui/lib/index.css' // [!code ++]
import '@univerjs/docs-drawing-ui/lib/index.css' // [!code ++]

const univer = new Univer({
  locale: LocaleType.ZH_CN,
  locales: {
    [LocaleType.ZH_CN]: mergeLocales(
      DrawingUIZhCN, // [!code ++]
      DocsDrawingUIZhCN, // [!code ++]
    ),
  },
})

univer.registerPlugin(UniverDrawingPlugin) // [!code ++]
univer.registerPlugin(UniverDrawingUIPlugin) // [!code ++]
univer.registerPlugin(UniverDocsDrawingPlugin) // [!code ++]
univer.registerPlugin(UniverDocsDrawingUIPlugin) // [!code ++]
```

如使用[协同编辑](/guides/docs/features/collaboration)功能，需要添加 `override` 配置：

```typescript
univer.registerPlugin(UniverDrawingPlugin, {
  override: [[IImageIoService, null]], // [!code ++]
})
```

{/* ### 插件与配置 */}
